const { getUserId } = require('../../utils')

const user = {
  async user(parent, { phone, id }, ctx, info) {
    if (!phone && !id) {
      throw new Error('need unique key for query user')
    }
    const userId = getUserId(ctx)
    return ctx.db.query.user({ where: { phone, id } }, info)
  }
}

module.exports = { user }
